<?php include "templates/header.php"; ?>
<?php
$categories = mysql_select_array("SELECT * FROM `category`");
if (isset($_POST['add_product'])) {
    foreach ($_POST as $key => $value) {
        if ($key != 'add_product') {
            $insert_fields[$key] = trim($value);
        }
    }
    mysql_insert('product', $insert_fields);
}
?>
Добавть продукт
<form action="" method="post">
    <input type="hidden" name="add_product" value="1" />
    <table border="0">
        <tr>
            <td style="text-align: right;">Наименование:</td>
            <td><input type="text" name="title" style="width: 300px;" /></td>
        </tr>
        <tr>
            <td style="text-align: right;">Категория:</td>
            <td>
                <select name="category_id" style="width: 300px;">
                    <option value="0">Выберите категорию</option>
                    <?  foreach ($categories as $key => $category):?>
                        <option value="<?=$category['id'];?>"><?=$category['title'];?></option>
                    <?  endforeach;?>
                </select>
            </td>
        </tr>
        <tr>
            <td style="text-align: right;">Описание:</td>
            <td><textarea name="description" style="width: 300px; height: 100px;"></textarea></td>
        </tr>
        <tr>
            <td style="text-align: right;">Опубликовать:</td>
            <td><input type="checkbox" name="active" value="1" /></td>
        </tr>
        <tr>
            <td style="text-align: right;"></td>
            <td><input type="submit" value="Добавить" /></td>
        </tr>

    </table>
</form>
<? include "templates/footer.php"; ?>